package com.doubi.vo;

import java.io.Serializable;
import java.util.HashMap;

public class AppModel implements Serializable {
    private int code;
    private String msg;
    private Object data;

    public AppModel(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public AppModel(int code, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = new HashMap<>().put("",null);
    }

    public AppModel() {
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


    public static AppModel success(){
        return new AppModel(0,"操作成功！");
    }

    public static AppModel success(String msg){
        return new AppModel(0,msg);
    }


    public static AppModel success(Integer code,String msg){
        return new AppModel(code,msg);
    }

    public static AppModel success(Integer code,String msg,Object obj){
        return new AppModel(code,msg,obj);
    }

    public static AppModel success(Object obj){
        return new AppModel(0,"获取成功！",obj);
    }

    public static AppModel error(){
        return new AppModel(-1,"操作失败！");
    }

    public static AppModel error(String msg){
        return new AppModel(-1,msg);
    }
}
